package com.joplus.housekeeper.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.joplus.housekeeper.R;
import com.joplus.housekeeper.bean.Interest;

import java.util.List;
import java.util.zip.Inflater;

/**
 * Created by zisheng on 2017/7/18.
 */

public class InterestHobyAdapter extends BaseAdapter {
    List<Interest.SonInterestListBean> interest;
    Context context;
    private final LayoutInflater layout;

    public InterestHobyAdapter(Context context, List<Interest.SonInterestListBean> interest) {
        this.context = context;
        this.interest = interest;
        layout = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return interest.size();
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
view = layout.inflate(R.layout.item_interest_hoby,null);
        TextView tv = (TextView) view.findViewById(R.id.tv);
        tv.setText(interest.get(i).getInterestName());
        if ("1".equals(interest.get(i).getStatus())) {
            tv.setBackgroundResource(R.drawable.shape_gold_coner_all);
            tv.setTextColor(context.getResources().getColor(R.color.white));
        }else{
            tv.setBackgroundResource(R.drawable.shape_2px_gray);
            tv.setTextColor(context.getResources().getColor(R.color.text_38));

        }

        return view;
    }
}
